<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      class Person {
        // 不需要传递参数的属性可以写成属性class字段
        money = 1000; //class字段
        constructor(a, b) {
          // 需要传递参数的属性必须要写到constructor内部，使用this对象定义
          this.useranme = a;
          this.age = b;
          // this.money = 1000;
        }
      }
      const p1 = new Person("lili", 20); // new constructor(lili,20)
      console.log(p1.useranme);
      console.log(p1.age);

      const p2 = new Person("jack", 21);
      console.log(p2.useranme);
      console.log(p2.age);

      console.log(p1.money);
      console.log(p2.money);
    </script>
  </body>
</html>
